home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Taifun / Taifun 007 (1987-02-15)(Ossowski, Stefan)(DE)(PD).zip / Taifun 007 (1987-02-15)(Ossowski, Stefan)(DE)(PD).adf / C Compiler / intexpr.c < prev    next >
C/C++ Source or Header  |  1987-03-04  |  2KB  |  54 lines

  1. #include        <stdio.h>
  2. #include        "c.h"
  3. #include        "expr.h"
  4. #include        "gen.h"
  5. #include        "cglbdec.h"
  6.  
  7. /*
  8.  *    68000 C compiler
  9.  *
  10.  *    Copyright 1984, 1985, 1986 Matthew Brandt.
  11.  *    all commercial rights reserved.
  12.  *
  13.  *    This compiler is intended as an instructive tool for personal use. Any
  14.  *    use for profit without the written consent of the author is prohibited.
  15.  *
  16.  *    This compiler may be distributed freely for non-commercial use as long
  17.  *    as this notice stays intact. Please forward any enhancements or questions
  18.  *    to:
  19.  *
  20.  *        Matthew Brandt
  21.  *        Box 920337
  22.  *        Norcross, Ga 30092
  23.  */
  24.  
  25. intexpr()       /* simple integer value */
  26. {       int     temp;
  27.         SYM     *sp;
  28.         if(lastst == id) {
  29.                 sp = search(lastid,lsyms.head);
  30.                 if( sp == NULL)
  31.                         sp = search(lastid,gsyms.head);
  32.                 if(sp == NULL) {
  33.                         error(ERR_UNDEFINED);
  34.                         getsym();
  35.                         return 0;
  36.                         }
  37.                 if(sp->storage_class != sc_const) {
  38.                         error(ERR_SYNTAX);
  39.                         getsym();
  40.                         return 0;
  41.                         }
  42.                 getsym();
  43.                 return sp->value.i;
  44.                 }
  45.         else if(lastst == iconst) {
  46.                 temp = ival;
  47.                 getsym();
  48.                 return temp;
  49.                 }
  50.         getsym();
  51.         error(ERR_SYNTAX);
  52.         return 0;
  53. }
  54.